{include file="public/header" /}

<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body ">
                    <form class="layui-form layui-col-space5">
                        <div class="layui-inline layui-show-xs-block">
                            <select name="status">
                                <option value="">投票状态</option>
                                <option value="1" {if !empty(input('get.status')) &&
                                    input('get.status')==1}selected{/if}>投票</option>
                                <option value="2" {if !empty(input('get.status')) &&
                                    input('get.status')==2}selected{/if}>未投票</option>
                            </select>
                        </div>
                        <div class="layui-inline layui-show-xs-block">
                            <input type="text" id="code" name="code" required="" lay-verify="required"
                                autocomplete="off" class="layui-input" value="{:input('get.code')}"
                                placeholder="投票任务ID">
                        </div>
                        <div class="layui-inline layui-show-xs-block">
                            <input type="text" id="mobile" name="mobile" required="" lay-verify="required"
                                autocomplete="off" class="layui-input" value="{:input('get.mobile')}"
                                placeholder="投票人ID|手机号">
                        </div>
                        <div class="layui-inline layui-show-xs-block">
                            <button class="layui-btn" lay-submit="" lay-filter="sreach">搜索</button>
                        </div>
                    </form>
                </div>
                <div class="layui-card-header">
                    <button class="layui-btn" onclick="data_edit('添加','/user/commvotestr?code={$code}')"><i
                        class="layui-icon">&#xe654;</i>添加投票用户</button>&nbsp;
                    共有数据：<strong id="count">{$list->total()}</strong> 条
                </div>
                <div class="layui-card-body layui-table-body layui-table-main">
                    <table class="layui-table layui-form" lay-size="sm">
                        <thead>
                            <tr>
                                <th width="">ID</th>
                                <th width="">用户信息</th>
                                <th width="">是否投票</th>
                                <th width="">投票价格</th>
                                <th width="">投票时间</th>
                            </tr>
                        </thead>
                        <tbody>
                            {foreach $list as $v}
                            <tr>
                                <td>{$v.id|default='0'}</td>
                                <td>{if $v.user_id > 0}
                                    用户ID：{$v.user_id|default='0'}<br />
                                    {else}
                                    用户ID：系统添加<br/>
                                    {/if}
                                    手机号:{$v.mobile|default='无'}
                                </td>
                                <td>{if $v.status == 1}投票{else}未投票{/if}</td>
                                <td>{$v.price|default='0'}</td>
                                <td>{$v.created|default=''}</td>
                            </tr>
                            {/foreach}

                        </tbody>
                    </table>
                </div>
                <div class="layui-card-body ">
                    <div class="page">
                        {$list->render()|raw}
                    </div>
                </div>

            </div>
        </div>
    </div>
</div>
</body>
<script>
    function orderstr(url) {
        layer.open({
            type: 1,
            title: '添加投票信息',
            area: ['400px', 'auto'],
            content: '<form style="padding:30px" class="layui-form" action=""><div class="layui-form-item"><label class="layui-form-label">投票日期：</label><div class="layui-input-block"><input type="text" id="date" name="dates" required  lay-verify="required" placeholder="请选择时间" autocomplete="off" class="layui-input"></div></div></form>',
            btn: ['添加', '取消'],
            success: function (layero, index) { // 弹窗成功
                layui.use(['laydate'], function () {
                    var $ = layui.jquery
                        , laydate = layui.laydate;
                    laydate.render({
                        elem: '#date',//指定元素
                        trigger: 'click'
                    });
                })
            },
            yes: function () {
                var dates = $('#date').val();
                $.post(url, { dates: dates }, function (data) {
                    if (data.status == 0) {
                        layer.msg(data.msg, { icon: 6, time: 1000 }, function () {
                            location.reload();
                            layer.close(index);
                        });
                    } else {
                        layer.msg(data.msg, { icon: 2, time: 1000 });
                    }
                });
            }
        });
    };
    layui.use(['upload', 'form', 'laydate'], function () {
        var $ = layui.jquery
            , laydate = layui.laydate
        laydate.render({
            elem: '#dates' //指定元素
        });
    });
    function showimg(imgs) {
        console.log(imgs);
        layer.open({
            type: 1,
            title: false,
            shadeClose: true,
            skin: 'layui-layer-nobg', //没有背景色
            content: "<img src='" + imgs + "' style='width:100%;height: 100%;'>"
        });
    }
</script>
{include file="public/footer"}